//
//  GMExplainCell.m
//  Teecloud
//
//  Created by 小熊 on 2018/11/12.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "GMExplainCell.h"
#import "GMSubjectsModel.h"
@interface GMExplainCell ()
@property (weak, nonatomic) IBOutlet UITextView *explain;

@end
@implementation GMExplainCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(void)setModel:(GMSubjectsModel *)model{
    _model = model;
    if (kIsEmptyString(model.Explain)) {
        self.explain.text = @"暂无解析";
        model.explanHight = 60;
    }else{
        NSDictionary *options = @{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType,NSFontAttributeName:@12};
        NSData *data = [model.Explain dataUsingEncoding:NSUnicodeStringEncoding];
        NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithData:data options:options documentAttributes:nil error:nil];
        NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
        style.lineSpacing=0;
        style.paragraphSpacing=0;
        [attri addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, attri.length)];
        self.explain.attributedText = attri;
        CGSize size = [self.explain sizeThatFits:CGSizeMake(DEVICE_WIDTH-30, 1000)];
        model.explanHight = size.height+40;
    }
}

@end
